package threadDemo1.join;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-27
 * Time: 14:21
 */
public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0;i < 3;i++){
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("Over Thread");
        });
        thread.start();
        //main等待thread线程执行完毕
        thread.join();
        //main线程恢复执行
        System.out.println("Hello Main");
    }
}
